<template>
  <div class="components-container" style="display: inline-block;vertical-align: top;margin: 0px;">
    <el-button type="primary" style="padding: 11px 20px;" @click="dialogTableVisible = true">添加</el-button>
    <el-dialog :visible.sync="dialogTableVisible" title="添加">
      <el-form ref="formData" label-position="left" label-width="70px" style="width: 400px; margin-left:50px;">
        <el-form-item :label="'name'" prop="name">
          <el-input v-model="formData.name"/>
        </el-form-item>
        <el-form-item :label="'role'" prop="role">
          <el-input v-model="formData.role"/>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm()">create</el-button>
          <el-button @click="close()">cancel</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import elDragDialog from '@/directive/el-dragDialog' // base on element-ui
import { add } from '@/api/shop_admin_auth/shopRole'
import store from '@/store'
export default {
  name: 'DragDialogDemo',
  directives: { elDragDialog },
  data() {
    return {
      dialogTableVisible: false,
      formData: {
      }
    }
  },
  methods: {
    submitForm() {
      add(store.getters.token, this.formData).then(res => {
        this.$emit('getLists')
        this.close()
      })
    },
    close() {
      this.dialogTableVisible = false
    }
  }
}
</script>
